<?
session_start();
include('conn.php');

$fromdt=$_SESSION['fromdt'];
$todt=$_SESSION['todt'];

$date=$_SESSION['todt'];
$day= substr($date,0,2);
$month = substr($date,3,2);
$year = substr($date,6,4);
$todt=$year.'-'.$month.'-'.$day;

$date=$_SESSION['fromdt'];
$day= substr($date,0,2);
$month = substr($date,3,2);
$year = substr($date,6,4);
$fromdt=$year.'-'.$month.'-'.$day;


//$qry1 = "SELECT * from expensemast where status=0 order by exptranid desc";
$qry1 = "SELECT exptranid,empname, expdate,t2.empid,expensecat,amtpaid,t2.entrydt,t2.enteredby,t2.status,comment from expensemast t1
left join employeemast t2 on t1.empid = t2.empid where t1.status=0 order by exptranid asc";
//and t2.expdate >='".$fromdt."' and t2.expdate <='".$todt."'" ;

$qry = mysql_query($qry1);
$data = array();
$i=1;
while($rows = mysql_fetch_array($qry))
{
$date = $rows['trndate'];
	$year= substr($date,0,4);
	$month = substr($date,5,2);
	$day = substr($date,8,2);
	$data[] = array("Sr_NO" => $i++,
        			"exptranid" => $rows['exptranid'],
					"expdate" => $rows['expdate'],
				  "empid" => $rows['empid'],
                  "empname" =>$rows['empname'],
				  "expensecat" => $rows['expensecat'],
				  "amtpaid"=> $rows['amtpaid'],
				  "comment"=> $rows['comment'],
				   "entrydt"=> $rows['entrydt'],
				  "enteredby"=> $rows['enteredby'],
                    "status"=> $rows['status']
                    );
}
echo json_encode($data);
?>